#include "toolbarwgt.h"
#include "ui_toolbarwgt.h"

ToolbarWgt::ToolbarWgt(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ToolbarWgt)
{
    ui->setupUi(this);

    initStyle();
    initConnect();
}

ToolbarWgt::~ToolbarWgt()
{
    delete ui;
}

void ToolbarWgt::initStyle()
{
    ui->openFileBtn->setToolTip(tr("Open file"));
    ui->openFileBtn->setIcon(QIcon(":/resource/svg/new-file.svg"));
    ui->openFileBtn->setFixedSize(30, 30);
    ui->openFileBtn->setCursor(Qt::PointingHandCursor);
    ui->catalogueBtn->setCheckable(true);
    ui->catalogueBtn->setChecked(true);
    ui->catalogueBtn->setIcon(QIcon(":/resource/svg/catalogue.svg"));
    ui->catalogueBtn->setToolTip(tr("Open catalogue"));
    ui->catalogueBtn->setFixedSize(30, 30);
    ui->catalogueBtn->setCursor(Qt::PointingHandCursor);
}

void ToolbarWgt::initConnect()
{
    connect(ui->openFileBtn, &QPushButton::clicked, this, &ToolbarWgt::openFile);
    connect(ui->catalogueBtn, &QPushButton::clicked, this, &ToolbarWgt::catalogueBtnClicked);
    connect(ui->miniWgtBtn, &QPushButton::clicked, this, &ToolbarWgt::miniWgtBtnClickedSlt);
}

void ToolbarWgt::openFile()
{
    Q_EMIT openFileSgl();
}

void ToolbarWgt::catalogueBtnClicked(bool checked)
{
    Q_EMIT catalogueBtnCheckedSgl(checked);
}

void ToolbarWgt::miniWgtBtnClickedSlt()
{
    Q_EMIT miniWgtBtnClickedSgl();
}
